<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-sys__user">
      <el-form
        :inline="true"
        :model="dataForm"
        @keyup.enter.native="getDataList()"
      >
        <el-form-item>
          <el-input
            v-model="dataForm.productLineName"
            placeholder="请输入产品线"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-input
            v-model="dataForm.brand"
            placeholder="请输入品牌"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-input
            v-model="dataForm.branch"
            placeholder="请输入车系名称"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-button @click="getDataList()">{{ $t("query") }}</el-button>
        </el-form-item>
        <el-form-item>
            <el-button  type="primary" @click="addOrUpdateHandle()">新增</el-button>
          </el-form-item>
          <el-form-item>
            <el-button type="danger" @click="deleteClick('','Batch')">批量删除</el-button>
          </el-form-item>
        <!-- <el-form-item>
            <el-button v-if="$hasPermission('sys:user:delete')" type="danger" @click="deleteHandle()">{{ $t('deleteBatch') }}</el-button>
          </el-form-item>
          <el-form-item>
            <el-button v-if="$hasPermission('sys:user:export')" type="info" @click="exportHandle()">{{ $t('export') }}</el-button>
          </el-form-item> -->
      </el-form>
      <el-table
        v-loading="dataListLoading"
        :data="dataList"
        border
        @selection-change="dataListSelectionChangeHandle"
        @sort-change="dataListSortChangeHandle"
        style="width: 100%"
        :header-cell-style="{height:'50px'}">
      >
        <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
        <el-table-column type="index" label="序号" header-align="center" align="center" width="50"></el-table-column>
        <el-table-column
          prop="productLineName"
          label="产品线"
          header-align="center"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="brandId"
          label="品牌id"
          header-align="center"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="brandChn"
          label="品牌名称"
          header-align="center"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="brandEng"
          label="品牌名称简称"
          header-align="center"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="branchChn"
          label="车系名称"
          header-align="center"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="branchEng"
          label="车系名称简称"
          header-align="center"
          align="center"
        ></el-table-column>
        <!-- <el-table-column
          prop="vdsName"
          label="车型名称"
          header-align="center"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="vdsNameChn"
          label="车型中文简称"
          header-align="center"
          align="center"
        ></el-table-column> -->
        <el-table-column
          prop="branchImage"
          label="车辆图片"
          header-align="center"
          align="center"
        >
          <div slot-scope="scope">
            <img :src="scope.row.branchImage" class="imgls" alt="" />
          </div>
        </el-table-column>
        <el-table-column
          prop="createBy"
          label="排序"
          header-align="center"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="status"
          label="状态"
          header-align="center"
          align="center"
        >
          <div slot-scope="scope">
            {{ scope.row.status == 0 ? "隐藏" :scope.row.status == 1? "显示":"-" }}
          </div>
        </el-table-column>
        <el-table-column
          :label="$t('handle')"
          fixed="right"
          header-align="center"
          align="center"
          width="150"
        >
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="HandleShow(scope.row)">
              {{ scope.row.status == 1 ? "隐藏" : " 显示" }}
            </el-button>
            <el-button
              type="text"
              size="small"
              @click="addOrUpdateHandle(scope.row.id)"
              >{{ $t("update") }}</el-button
            >
            <el-button
              type="text"
              size="small"
              @click="deleteClick(scope.row.id,'single')"
              >{{ $t("delete") }}</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        :current-page="page"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="limit"
        :total="total"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="pageSizeChangeHandle"
        @current-change="pageCurrentChangeHandle"
      >
      </el-pagination>
      <!-- 弹窗, 新增 / 修改 -->
      <add-or-update
        v-if="addOrUpdateVisible"
        ref="addOrUpdate"
        @canCle="canCle"
        @refreshDataList="getDataList"
      ></add-or-update>
    </div>
  </el-card>
</template>
  
  <script>
import mixinViewModule from "@/mixins/view-module";
import AddOrUpdate from "./car-add-update";
export default {
  mixins: [mixinViewModule],
  data() {
    return {
      mixinViewModuleOptions: {
        getDataListURL: "/findbrandbranchvds/page",
        getDataListIsPage: true,
        deleteURL: "/findbrandbranchvds/delete",
        deleteIsBatch: true,
        exportURL: "/sys/user/export",
        
      },
      dataForm: {
        brand:"",
        branch:"",
        vds:""
      },
    };
  },
  components: {
    AddOrUpdate,
  },
  methods: {
    HandleShow(val) {
        console.log(val,'1111111111')
      let word = val.status == 1 ? "隐藏" : "显示";
      let that = this
      that.$confirm("是否确认" + word, "提示", {
        confirmButtonText: "确认", //确认按钮文字更换
        cancelButtonText: "取消", //取消按钮文字更换
        showClose: true, //是否显示右上角关闭按钮
        type: "warning", //提示类型  success/info/warning/error
      })
        .then(function () {
            that.show(val.id,val.status);
        })
        .catch(function (err) {});
    },
    show(id, type) {
        let Status = type == 1?0:1
      this.$http
        .get("findbrandbranchvds/updateStatus", {
          params: {
            id,
            Status,
          },
        })
        .then((res) => {
          this.query()
        });
    },
  },
};
</script>
  <style scoped lang="scss">
   ::v-deep .el-table .cell{
    // height: 150px;
   }
   .imgls{
    width: 100px;
    height: 100px;
    background-size: 100% 100%;
   }
  </style>